﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ThongTin;
using ThaoTac;
using DuLieu;

namespace GiaoDien
{
    public partial class frmQuanLyLopHoc : Form
    {
        public string ChucNang;
        public frmQuanLyLopHoc(String ChucNang, Lop_TT Lop)
        {
            InitializeComponent();
            this.ChucNang = ChucNang;
            if (ChucNang.Equals("Sua"))
            {
                txtMaLop.Text = Lop.MaLop;
                txtTenLop.Text = Lop.TenLop;
                cbHeDaoTao.Text = Lop.MaHeDaoTao;
                cbKhoaHoc.Text = Lop.MaKhoaHoc;
                cbNganh.Text = Lop.MaNganh;
            }
        }
        public String MaLop
        {
            get { return txtMaLop.Text; }
        }
        public String TenLop
        {
            get { return txtTenLop.Text; }
        }
        public String KhoaHoc
        {
            get { return cbKhoaHoc.Text; }

        }
        public String HeDaoTao
        {
            get { return cbHeDaoTao.Text; }

        }
        public String Nganh
        {
            get { return cbNganh.Text; }
        }
        public event EventHandler addNew;
        private void btnXacNhan_QLL_Click(object sender, EventArgs e)
        {
            EventHandler eh = addNew;
            if (eh != null)
                eh(this, e);
            if (this.ChucNang.Equals("Sua"))
            { this.Close(); }
            if (this.ChucNang.Equals("Them"))
            { this.Close(); }
        }

        private void btnThoat_QLL_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void frmQuanLyLopHoc_Load(object sender, EventArgs e)
        {
            load();
        }
        private void load()
        { 
            loadcombobox load = new loadcombobox();
            //load nen khoa
            
            cbKhoaHoc.DisplayMember = "MaKhoaHoc";
            cbKhoaHoc.DataSource = load.loadcombox("Lop").Tables[0];

            // 
            cbHeDaoTao.DisplayMember = "MaHe";
            //cbHeDaoTao.ValueMember = "MaHe";
            cbHeDaoTao.DataSource = load.loadcombox("HeDaoTao").Tables[0];
            //
            cbNganh.DisplayMember = "MaNganh";
            //cbNganh.ValueMember = "MaNganh";
            cbNganh.DataSource = load.loadcombox("NganhDaoTao").Tables[0];
        }

    }
}
